package com.xss.audioandvideo_2;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewStub;
import android.widget.Toast;

/**
 * 实现布局优化
 * 1.少嵌套（用RelativeLayout）
 * 2.使用<include>和<merge>标签
 * 3.使用Viewstub实现按需加载
 */
public class LayoutActivity extends AppCompatActivity {
    private static final String TAG = "xss";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_layout);
    }

    public void showViewStub(View view) {
        ViewStub viewStub = findViewById(R.id.viewstub);
        if (viewStub!=null){//ViewStub只能加载一次，加载过后viewstub被其内部布局取代
            View importLayout=viewStub.inflate();
        }
    }
}
